package JUC_stady;

import java.util.concurrent.TimeUnit;

/**
 * Project: tobe-better-coder
 * Package: JUC_stady
 *
 * @author : Mr.xu
 * @date : 2023/3/21 1:04
 */
public class VolatileDemo {

    private volatile static boolean flag = true;

    public static void main(String[] args) {
        new Thread(() -> {
            while (flag) {
//                System.out.println("....");
            }
            System.out.println("执行完毕");
        }).start();

        try {
            TimeUnit.SECONDS.sleep(2);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        flag = false;
    }
}